<template>
  <div>
    <div class="list" @click="clickItem(item)" v-for="(item, index) in priceList" :key="index">
      <img class="typeImg" :src="typeImg" alt="">
      <ul >
        <li>{{item.item_id}}</li>
        <li class="time" v-show="item.duration">
          <img class="timeimg" src="../../../assets/预约时间@2x.png" alt="">
          {{item.duration}}分钟
        </li>
        <li class="teamLi">
<!--          <router-link :to="{path: '/LookTeamHome', query: {userid: userid,-->
<!--           team_id: team_id,-->
<!--          id: team_id,-->
<!--          topActive: 3}}">-->
          <span style="color: #1da4f2" @click.stop="lookTeam(item)">
            {{item.team_name}}
            <img src="../../../assets/更多蓝.png" alt="">
          </span>
<!--          </router-link>-->
          <span class="price">￥{{item.rebate_amount}}/次</span>
        </li>
      </ul>
    </div>
    <van-loading v-show="isLoading" size="24px" style="width: 100%;height: 80vh;
    display:flex;align-items:center;justify-content:center; color: #1da4f2" vertical>
      加载中...
    </van-loading>
    <van-empty
      style="width: 100%;height: 60vh"
      v-show="priceList.length <= 0 && isLoading === false"
      class="custom-image"
      :image="require('../../../assets/空两本书.png')"
      :description=" `暂无`+emptyText+`数据`"
    />
  </div>
</template>

<script>
export default {
  name: 'JuJiaXiangmu',
  data () {
    return {
      userid: this.$route.query.userid,
      team_id: this.$route.query.team_id,
      type: this.$route.query.type,
      title: '',
      priceList: [],
      teamInfo: [],
      isLoading: true
    }
  },
  computed: {
    typeImg () {
      let img = ''
      if (this.type == 3) {
        return require('../../../assets/康复@2x.png')
      } else if (this.type == 4) {
        return require('../../../assets/护理@2x.png')
      } else if (this.type == 6) {
        return require('../../../assets/居家生活.png')
      } else if (this.type == 7) {
        return require('../../../assets/养老.png')
      }
    },
    searchVal () {
      let val = ''
      if (this.$route.query.searchVal) {
        val = this.$route.query.searchVal
      }
      return val
    },
    emptyText () {
      let text = ''
      if (this.searchVal) {
        text = '符合条件'
      }
      return text
    }
  },
  watch: {
    searchVal (val1, val2) {
      if (val1 !== val2) {
        this.getPriceList()
      }
    }
  },
  mounted () {
    if (this.$route.query.title) {
      this.title = this.$route.query.title
    } else {
    }
    this.getPriceList()
  },
  methods: {
    // 查看团队主页
    lookTeam (item) {
      this.$router.push({path: '/LookTeamHome',
        query: {userid: this.userid,
          team_id: this.team_id,
          id: item.team_id,
          topActive: 3}})
    },
    clickItem (item) {
      if (item.schedulelist && item.schedulelist.length <= 0) {
        this.$toast('近七天无可以预约号源')
        return false
      } else {
        this.$router.push({path: '/ServiceItemsJuJia',
          query: {userid: this.userid,
            team_id: item.team_id,
            type: this.type,
            id: item.id}})
      }
    },
    getPriceList () {
      this.isLoading = true
      this.$http.findTeamPrice({
        item_type: this.type,
        name: this.searchVal,
        is_show_team: '1',
        is_show_schedule: 1,
        team_id: this.team_id})
        .then(res => {
          console.log(res)
          if (res.data.status === 'success') {
            this.priceList = res.data.data
            this.isLoading = false
          } else {
            this.isLoading = false
            this.$toast(res.data.msg)
          }
        })
        .catch(err => {
          this.isLoading = false
          console.log(err)
          this.$toast('您的网络有些拥挤，请稍后再试')
        })
    }
  }
}
</script>

<style scoped lang="scss">
.list{
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: row;
  background: #FFFFFF;
  margin-bottom: 8px;
  padding: 10px 15px;
  box-sizing: border-box;
  ul{
    flex: 2;
    margin-left: 10px;
    li{
      min-height: 25px;
      display: flex;
      align-items: center;
    }
    .time{
      font-size: 13px;
      color: #999999;
    }
    .teamLi{
      justify-content: space-between;
      img {
        width: 7px;
        height: 12px;
      }
    }
  }
}
.timeimg{
  width: 16px;
  height: 16px;
}
.typeImg{
  width: 60px;
  height: 60px;
}
.price{
  color: #E3170D;
}
</style>
